package com.javaweb.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.javaweb.admin.entity.KDLCustomer;
import com.javaweb.admin.entity.KDLCustomerLog;
import com.javaweb.admin.entity.KDLMaterial;
import com.javaweb.admin.entity.KDLMaterialLog;
import com.javaweb.admin.query.KDLCustomerQuery;
import com.javaweb.admin.query.KDLMaterialQuery;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface KDLMaterialMapper extends BaseMapper<KDLMaterial> {
    IPage<KDLMaterial> getMaterialList(IPage<KDLMaterial> page, @Param("req") KDLMaterialQuery req);

    @Select("select * from v_kdl_invlist where ncts>=#{ncts}")
    List<KDLMaterial> GetNCMaterialList(String ncts);

    @Select("select * from v_kdl_invlist where ncts>'2024-01-01' and materialcode not in (select materialcode from kdl_material)")
    List<KDLMaterial> GetNCMaterialMissList(String ncts);

    @Select("select isnull(max(convert(varchar(20),ncts,120)),'') from kdl_material")
    String GetMaxNCTS();

    @Select("select distinct materialgroup from kdl_material order by materialgroup")
    List<String> getMaterialGroup();



    @Select("select * from kdl_material_log where materialcode=#{materialcode} order by ncts desc")
    List<KDLMaterialLog> GetNCMaterialLogList(String materialcode);

    @Select("select distinct qcusername from kdl_material order by qcusername")
    List<String> getQCUserList();

    @Select("select TOP 1 * from v_kdl_invlist where materialcode = #{itemno}")
    KDLMaterial getMaterialByCode(String itemno);
}
